package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 查询医院科室排班信息
 */
@RestController
@RequestMapping("/user/schedule")
public class UserScheduleController {

    @Autowired
    private ScheduleService scheduleService;


    /**
     *
     * @param pageSize 一页显示多少条
     * @param pageNum 显示第几页
     * @param hoscode 医院编号
     * @param depcode 科室编号
     * @return 将分页信息,医院编号,科室编号返回给前端
     */
    @GetMapping("/{pageNum}/{pageSize}/{hoscode}/{depcode}")
    public R page(@PathVariable Integer pageSize, @PathVariable Integer pageNum,@PathVariable String hoscode,@PathVariable String depcode){
        Map<String,Object> map = scheduleService.getUserSchedulePage(pageNum,pageSize,hoscode,depcode);
        return R.ok().data(map);
    }

    //查询排班详情信息
    @GetMapping("/{hoscode}/{depcode}/{workDate}")
    public R page(@PathVariable String hoscode,@PathVariable String depcode,@PathVariable String workDate){
        List<Schedule> scheduleDetail = scheduleService.getScheduleDetail(hoscode, depcode, workDate);
        return R.ok().data("items",scheduleDetail);
    }

    //根据排班id获取排班信息的接口
    @GetMapping("/{scheduleId}")
    public R getScheduleById(@PathVariable String scheduleId){
        Schedule schedule = scheduleService.getScheduleById(scheduleId);
        return R.ok().data("item",schedule);
    }

    @GetMapping("/remote/{scheduleId}")
    public ScheduleOrderVo getRemoteScheduleById(@PathVariable String scheduleId){
        return scheduleService.getRemoteScheduleById(scheduleId);
    }
}